package com.blue.seata.storage.api.fallback;

import com.blue.seata.common.JsonResult;
import com.blue.seata.storage.api.remote.RemoteStorageService;
import lombok.Setter;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Component;

/**
 * 接口降级策略
 *
 * @author liulei
 * @version 1.0
 */
@Component
public class RemoteStorageServiceFallBackImpl implements RemoteStorageService {

    private static final Logger logger = LoggerFactory.getLogger(RemoteStorageServiceFallBackImpl.class);

    @Setter
    private Throwable cause;

    @Override
    public JsonResult minus(String code, Integer count) {
        logger.error("远程调用库存[storage] feign 调用接口[{}]失败", "createOrder", cause);
        return JsonResult.failed(cause.getMessage());
    }
}
